<?php TPL::output('global/header.tpl.htm'); ?>
<style>
	.aw-main-content{
		background-color: #BED8FF;
	}
	.sort-title{
		background-image: url(static/admin/img/wastepaper.png);
		z-index: 2;
		margin-top:0px;
		width:732px;
		height:170px;
	}
	.sort-title img{
		margin-left: 120px;
		margin-top: 50px;
	}
	.sort-body{
    	width:705px;
		height:1170px;
		margin-top:-75px;
		margin-left:12px;
		margin-right:12px;
        z-index: 1;
		background-image: url(static/admin/img/bg_box.png);
	}
	.sort_table{
		width:650px;
		margin-top:20px;
		margin-left:35px;
		padding-bottom: 40px;

	}
	.sort_table tr{
		height:39px;
		text-align: center;
	}
	.table-striped>tbody>tr:nth-child(odd)>td, .table-striped>tbody>tr:nth-child(odd)>th{
		background: white;
	}
	 .table>tbody>tr>th, .table>tfoot>tr>th,  .table>tbody>tr>td, .table>tfoot>tr>td{
		background: #f4f7fc;
	}

</style>
<div class="aw-container-wrap">
	<div class="container">
		<div class="row">
			<div class="aw-content-wrap clearfix">
				<div class="col-sm-12 col-md-9 aw-main-content">
					<div class="aw-mod aw-mod-invite-friend">
						<div class="mod-sort">
							<div class="sort-title">
								<img id="img1"  src="static/admin/img/text_title.png"/>
							</div>
							<div class="sort-body">
								<div style="padding-top:133px;padding-left:50px;">
									<!--<p style="display: inline-block;color:#FFFFFF ;font-size:28px;">当前排名：</p>
									<p style="display: inline-block;padding-left:143px;font-size: 48px;color: #FF827D;letter-spacing: 2px;line-height: 48px;"><?php if($this->sort){ echo $this->sort;}else{echo '- -';}?></p>-->
								</div>
								<div style="background-color: white;" class="sort_table">
									<form action="invitation/ajax/invitation_sort_list" method="post" onsubmit="return false;">
										<table class="table table-striped table-list">
											<thead>
											<tr>
												<th width="15%" style="text-align: center"><span style="padding: 5px 25px; background: #a0b9dd;color: #fff;font-size: 14px;border-radius: 22px;">名次</span></th>
												<th width="35%" style="text-align: center"><span style="padding: 5px 25px; background: #a0b9dd;color: #fff;font-size: 14px;border-radius: 22px;">用户名</span></th>
												<th width="25%" style="text-align: center"><span style="padding: 5px 25px; background: #a0b9dd;color: #fff;font-size: 14px;border-radius: 22px;">邀请人数</span></th>
												<th width="25%" style="text-align: center"><span style="padding: 5px 25px; background: #a0b9dd;color: #fff;font-size: 14px;border-radius: 22px;">收益</span></th>
											</tr>
											</thead>
											<tbody id="invitation_list2">

											</tbody>

										</table>
									</form>
									<div class="mod-table-foot" style="margin-left:560px;display: inline-block;">
										<a id="invitation_list_last" data-page="0"  onclick="load_invite_view(G_BASE_URL + '/invitation/ajax/invitation_sort_list/', $('#invitation_list_last'),  $('#invitation_list2'));"><img src="static/admin/img/previous_non.png"/></a>
										<span id="previous">2</span><span id="next">/<?php echo $this->total_page;?></span>
										<a id="invitation_list_next" data-page="2"  onclick="load_invite_view(G_BASE_URL + '/invitation/ajax/invitation_sort_list/', $('#invitation_list_next'),  $('#invitation_list2'));"><img src="static/admin/img/next_non.png"/></a>
									</div>
									<input type="hidden" id="total_page" value="<?php echo $this->total_page;?>"/>
								</div>
							</div>
						</div>
					</div>
				</div>

				<!-- 侧边栏 -->
				<div class="col-sm-12 col-md-3 aw-side-bar">
					<?php TPL::output('block/sidebar_menu.tpl.htm'); ?>
				</div>
				<!-- end 侧边栏 -->
			</div>
		</div>
	</div>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $('#invitation_list_last').click();
    });
var first_load =true;
// 加载更多
function load_invite_view(url, selector, container, topage, start_page, callback)
{
    if (!selector.attr('id'))
    {
        return false;
    }

    if (!start_page)
    {
        start_page = 0
    }

    // 把页数绑定在元素上面
    if (selector.attr('data-page') == undefined)
    {
        selector.attr('data-page', start_page);
    }
    else
    {
        selector.attr('data-page', parseInt(selector.attr('data-page')));
    }
        $.get(url + '?page=' + selector.attr('data-page'), function (result)
        {
            if ($.trim(result) != '')
            {
                first_load =false;
                container.html(result);
                // 页数增加1
                if(selector.attr('data-page') != 0 && selector.attr('id')=='invitation_list_last'){
					$('#previous').html(parseInt($('#previous').html())-1);
                    selector.attr('data-page', parseInt(selector.attr('data-page')) -1);
                    $('#invitation_list_next').attr('data-page', parseInt($('#invitation_list_next').attr('data-page')) -1);
                }else if(selector.attr('data-page') != 0 && selector.attr('id')=='invitation_list_next'){
                    $('#previous').html(parseInt($('#previous').html())+1);
                    selector.attr('data-page', parseInt(selector.attr('data-page')) + 1);
                    $('#invitation_list_last').attr('data-page', parseInt($('#invitation_list_last').attr('data-page')) +1);
                }else{
                    $('#previous').html(parseInt($('#previous').html())-1);
                    selector.attr('data-page', parseInt(selector.attr('data-page')) -1);
                    $('#invitation_list_next').attr('data-page', parseInt($('#invitation_list_next').attr('data-page')) -1);
				}

				if($('#invitation_list_last').attr('data-page')==-1){
                    $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_non.png');
				}else{
                    $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_def.png');
				}
                if($('#invitation_list_next').attr('data-page')==$('#total_page').val()){
                    $('#invitation_list_next').find('img').attr('src','static/admin/img/next_non.png');
                }else{
                    $('#invitation_list_next').find('img').attr('src','static/admin/img/next_def.png');
                }
                $('#invitation_list_last').mouseover(function(){
                    if($('#invitation_list_last').attr('data-page')!=-1) {
                        $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_click.png');
                    }
				});
                $('#invitation_list_last').mouseleave(function(){
                    if($('#invitation_list_last').attr('data-page')==-1){
                        $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_non.png');
                    }else{
                        $('#invitation_list_last').find('img').attr('src','static/admin/img/previous_def.png');
                    }
                });
                $('#invitation_list_next').mouseover(function(){
                    if($('#invitation_list_next').attr('data-page')!=$('#total_page').val()) {
                        $('#invitation_list_next').find('img').attr('src','static/admin/img/next_click.png');
                    }
                });
                $('#invitation_list_next').mouseleave(function(){
                    if($('#invitation_list_next').attr('data-page')==$('#total_page').val()){
                        $('#invitation_list_next').find('img').attr('src','static/admin/img/next_non.png');
                    }else{
                        $('#invitation_list_next').find('img').attr('src','static/admin/img/next_def.png');
                    }
                });
            }else{
                if(first_load == true){
                    first_load =false;
                    $('#previous').html(parseInt($('#previous').html())-2);
                }
            }
            if (callback != null)
            {
                callback();
            }
        });

        return false;

}
</script>

<?php TPL::output('global/footer.tpl.htm'); ?>